<html>
<body>
<FORM METHOD = "POST" ACTION ="test.php">
<TEXTAREA NAME="area" ROWS=5 COLS=30>
</TEXTAREA>
<INPUT TYPE="submit" VALUE="done">
</FORM>
<?php
$temp = $_POST["area"];
//echo "mysql_quert". $temp . "HERE";

$db_connection = mysql_connect("localhost", "cs143", "");
mysql_select_db("CS143", $db_connection);
$query = $temp;
$rs = mysql_query($query, $db_connection);
$num = mysql_num_fields($rs);
//echo "number=".$num."  ";
for($k=0; $k<$num; $k++)
{
    $col = mysql_fetch_field($rs);
    echo $col->name."    ";
}
echo "<br />";
while($row = mysql_fetch_row($rs)) {
    $id = $row[0];
    $title = $row[1];
    $year = $row[2];
    $rating = $row[3];
    $email = $row[4];
    print "$id, $title, $year, $rating, $email<br />";
}
mysql_close($db_connection);
?>

</body>
</html>